#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>
int my_atoi(const char* str)
{
	assert(str);
	if (*str == '\0')
		return 0;
	int n = 0;
	int flag = 1;
	while (*str == ' ') {
		str++;
	}
	if (*str == '+') {
		flag = 1;
		str++;
	}
	if (*str == '-') {
		flag = -1;
		str++;
	}
	while (*str != '\0') {
		if (*str >= '0' && *str <= '9') {
			n = n * 10 + (*str - '0');
		}
		else {
			break;
		}
		str++;
	}
		n *= flag;
		return (int)n;
}
int main()
{
	const char num[20] = "      -123456";
	int ret = my_atoi(num);
	printf("%d", ret);
	return 0;
}